import java.util.ArrayDeque;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 刘远望
 * Date: 2025-04-14
 * Time: 22:05
 */
//用栈来实现队列
public class MyQueue {
    public ArrayDeque<Integer> stack1 = new ArrayDeque<>();
    public ArrayDeque<Integer> stack2 = new ArrayDeque<>();

    public void push(int val){
        stack1.push(val);
    }

    public int pop(){
        if(empty()){
            return -1;
        }
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.pop();
    }

    public int peek(){
        if(empty()){
            return -1;
        }
        if(stack2.isEmpty()){
            while(!stack1.isEmpty()){
                stack2.push(stack1.pop());
            }
        }
        return stack2.peek();
    }

    public boolean empty(){
        return stack1.isEmpty() &&stack2.isEmpty();
    }
}
